import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:xin_nuo_pda/values/colors.dart';

import '/utils/string_extension.dart';
import 'IndexController.dart';

class IndexPage extends StatelessWidget {
  final IndexController logic = Get.put(IndexController());

  @override
  Widget build(BuildContext context) {
    return SingleChildScrollView(
      child: Container(
        padding: EdgeInsets.all(12),
        color: Colors.white,
        child: GetBuilder<IndexController>(
            builder: (logicGet) => Column(
                  children: [
                    Offstage(
                      offstage: logic.productList.length <= 0,
                      child: Row(
                        children: [
                          Container(
                            color: theme_blue.toColor(),
                            width: 4,
                            height: 16,
                          ),
                          SizedBox(
                            width: 4,
                          ),
                          Text(
                            "生产",
                            style: TextStyle(
                                fontSize: 16, fontWeight: FontWeight.bold),
                          ),
                        ],
                      ),
                    ),
                    SizedBox(
                      height: 4,
                    ),
                    Divider(
                      height: 1,
                      color: bg_gray.toColor(),
                    ),
                    GridView.builder(
                        shrinkWrap: true,
                        physics: NeverScrollableScrollPhysics(),
                        gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
                            crossAxisCount: 3, //每行三列
                            childAspectRatio: 1.5 //显示区域宽高相等
                            ),
                        itemCount: logic.productList.length,
                        itemBuilder: (context, index) {
                          return Material(
                            color: Colors.white,
                            child: Ink(
                              child: InkWell(
                                  onTap: () {
                                    Get.toNamed(
                                        logic.productList[index].skipClass!);
                                  },
                                  child: Column(
                                    mainAxisAlignment: MainAxisAlignment.center,
                                    children: [
                                      Image.asset(
                                        "assets/images/" +
                                            logic.productList[index].picName! +
                                            ".png",
                                        fit: BoxFit.cover,
                                        color: theme_blue.toColor(),
                                      ),
                                      SizedBox(height: 10),
                                      Text(
                                        logic.productList[index].text!,
                                      )
                                    ],
                                  )),
                            ),
                          );
                        }),
                    Offstage(
                      offstage: logic.tmtList.length <= 0,
                      child: Row(
                        children: [
                          Container(
                            color: theme_blue.toColor(),
                            width: 4,
                            height: 16,
                          ),
                          SizedBox(
                            width: 4,
                          ),
                          Text(
                            "TMT测试",
                            style: TextStyle(
                                fontSize: 16, fontWeight: FontWeight.bold),
                          ),
                        ],
                      ),
                    ),
                    SizedBox(
                      height: 4,
                    ),
                    Divider(
                      height: 1,
                      color: bg_gray.toColor(),
                    ),
                    GridView.builder(
                        shrinkWrap: true,
                        physics: NeverScrollableScrollPhysics(),
                        gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
                            crossAxisCount: 3, //每行三列
                            childAspectRatio: 1.5 //显示区域宽高相等
                            ),
                        itemCount: logic.tmtList.length,
                        itemBuilder: (context, index) {
                          return Material(
                            color: Colors.white,
                            child: Ink(
                              child: InkWell(
                                  onTap: () {
                                    Get.toNamed(logic.tmtList[index].skipClass!,
                                        arguments:
                                            logic.tmtList[index].showPlugin);
                                  },
                                  child: Column(
                                    mainAxisAlignment: MainAxisAlignment.center,
                                    children: [
                                      Image.asset(
                                        "assets/images/" +
                                            logic.tmtList[index].picName! +
                                            ".png",
                                        fit: BoxFit.cover,
                                        color: theme_blue.toColor(),
                                      ),
                                      SizedBox(height: 10),
                                      Text(
                                        logic.tmtList[index].text!,
                                      )
                                    ],
                                  )),
                            ),
                          );
                        }),
                    Offstage(
                      offstage: logic.eqpList.length <= 0,
                      child: Row(
                        children: [
                          Container(
                            color: theme_blue.toColor(),
                            width: 4,
                            height: 16,
                          ),
                          SizedBox(
                            width: 4,
                          ),
                          Text(
                            "设备",
                            style: TextStyle(
                                fontSize: 16, fontWeight: FontWeight.bold),
                          ),
                        ],
                      ),
                    ),
                    SizedBox(
                      height: 4,
                    ),
                    Divider(
                      height: 1,
                      color: bg_gray.toColor(),
                    ),
                    GridView.builder(
                        shrinkWrap: true,
                        physics: NeverScrollableScrollPhysics(),
                        gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
                            crossAxisCount: 3, //每行三列
                            childAspectRatio: 1.5 //显示区域宽高相等
                            ),
                        itemCount: logic.eqpList.length,
                        itemBuilder: (context, index) {
                          return Material(
                            color: Colors.white,
                            child: Ink(
                              child: InkWell(
                                  onTap: () {
                                    Get.toNamed(logic.eqpList[index].skipClass!,
                                        arguments:
                                            logic.eqpList[index].showPlugin);
                                  },
                                  child: Column(
                                    mainAxisAlignment: MainAxisAlignment.center,
                                    children: [
                                      Image.asset(
                                        "assets/images/" +
                                            logic.eqpList[index].picName! +
                                            ".png",
                                        fit: BoxFit.cover,
                                        color: theme_blue.toColor(),
                                      ),
                                      SizedBox(height: 10),
                                      Text(
                                        logic.eqpList[index].text!,
                                      )
                                    ],
                                  )),
                            ),
                          );
                        }),
                    Offstage(
                      offstage: logic.qaList.length <= 0,
                      child: Row(
                        children: [
                          Container(
                            color: theme_blue.toColor(),
                            width: 4,
                            height: 16,
                          ),
                          SizedBox(
                            width: 4,
                          ),
                          Text(
                            "QA",
                            style: TextStyle(
                                fontSize: 16, fontWeight: FontWeight.bold),
                          ),
                        ],
                      ),
                    ),
                    SizedBox(
                      height: 4,
                    ),
                    Divider(
                      height: 1,
                      color: bg_gray.toColor(),
                    ),
                    GridView.builder(
                        physics: NeverScrollableScrollPhysics(),
                        shrinkWrap: true,
                        gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
                            crossAxisCount: 3, //每行三列
                            childAspectRatio: 1.5 //显示区域宽高相等
                            ),
                        itemCount: logic.qaList.length,
                        itemBuilder: (context, index) {
                          return Material(
                            color: Colors.white,
                            child: Ink(
                              child: InkWell(
                                  onTap: () {
                                    Get.toNamed(logic.qaList[index].skipClass!);
                                  },
                                  child: Column(
                                    mainAxisAlignment: MainAxisAlignment.center,
                                    children: [
                                      Image.asset(
                                        "assets/images/" +
                                            logic.qaList[index].picName! +
                                            ".png",
                                        fit: BoxFit.cover,
                                        color: theme_blue.toColor(),
                                      ),
                                      SizedBox(height: 10),
                                      Text(
                                        logic.qaList[index].text!,
                                      )
                                    ],
                                  )),
                            ),
                          );
                        })
                  ],
                )),
      ),
    );
  }
}
